package com.jse.dao;

import java.sql.Connection;

import org.nutz.dao.ConnCallback;
import org.nutz.dao.impl.NutDao;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceUtils;

public class Dao extends NutDao {

	JdbcTemplate jdbcTemplate;

	@Override//spring声明事务管理修改
	public void run(ConnCallback callback) {  
	    Connection con = DataSourceUtils.getConnection(getDataSource());  
	    try {  
	        callback.invoke(con);  
	    } catch (Exception e) {  
	        if (e instanceof RuntimeException)  
	            throw (RuntimeException) e;  
	        else  
	            throw new RuntimeException(e);  
	    } finally {  
	        DataSourceUtils.releaseConnection(con, getDataSource());  
	    } 
	}

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
}
